package com.lb.jwitter.action;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Map; 
import org.springframework.test.context.ContextConfiguration; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.util.ApplicationContextProvider; 
import java.util.Collection;
import java.util.ArrayList;
import java.util.List;
import com.lb.jwitter.service.ConditionReport;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhi;
import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhiService;
import com.lb.jwitter.service.TblQLDTTXAHocVien;
import com.lb.jwitter.service.TblQLDTTXAHocVienService;

import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNam;
import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNamService;

import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhiMonHoc;
import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhiMonHocService;

import com.lb.jwitter.service.TblQLDTTXAMonHoc;
import com.lb.jwitter.service.TblQLDTTXAMonHocService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXAHocVienHocPhiEditFormAction{
    private int pageSize; 
    public int getPageSize() {
       return pageSize;
 }

    public void setPageSize(int pageSize) { this.pageSize = pageSize; }

    private int page; 
    public int getPage() { return page; }

    public void setPage(int page) { this.page = page; }

    private int pages; 
    public int getPages() { return pages; }

    public void setPages(int pages) { this.pages = pages; }

    private int id; 
    public int getId() { return id; }

    public void setId(int id) { this.id = id; }

    private TblQLDTTXAHocVienHocPhi tblQLDTTXAHocVienHocPhi; 
    public TblQLDTTXAHocVienHocPhi getTblQLDTTXAHocVienHocPhi() { 
        return tblQLDTTXAHocVienHocPhi; 
    } 
    private Collection<TblQLDTTXAHocVienHocPhi> tblQLDTTXAHocVienHocPhis; 
    public Collection<TblQLDTTXAHocVienHocPhi>  getTblQLDTTXAHocVienHocPhis() {
         return tblQLDTTXAHocVienHocPhis; 
      } 

    private TblQLDTTXAHocVienHocPhiService tblQLDTTXAHocVienHocPhiService; 

    private Collection<TblQLDTTXAHocVien> tblQLDTTXAHocViens; 
    public Collection<TblQLDTTXAHocVien>  getTblQLDTTXAHocViens(){ 
              return tblQLDTTXAHocViens; 
     } 

    private TblQLDTTXAHocVienService tblQLDTTXAHocVienService; 

    private Collection<TblQLDTTXAHocKyTrongNam> tblQLDTTXAHocKyTrongNams; 
    public Collection<TblQLDTTXAHocKyTrongNam>  getTblQLDTTXAHocKyTrongNams(){ 
              return tblQLDTTXAHocKyTrongNams; 
     } 

    private TblQLDTTXAHocKyTrongNamService tblQLDTTXAHocKyTrongNamService; 

    private Collection<TblQLDTTXAHocVienHocPhiMonHoc> tblQLDTTXAHocVienHocPhiMonHocs; 
    public Collection<TblQLDTTXAHocVienHocPhiMonHoc>  getTblQLDTTXAHocVienHocPhiMonHocs(){ 
              return tblQLDTTXAHocVienHocPhiMonHocs; 
     } 

    private TblQLDTTXAHocVienHocPhiMonHocService tblQLDTTXAHocVienHocPhiMonHocService; 

    private Collection<TblQLDTTXAMonHoc> tblQLDTTXAMonHocs; 
    public Collection<TblQLDTTXAMonHoc>  getTblQLDTTXAMonHocs(){ 
              return tblQLDTTXAMonHocs; 
     } 

    private TblQLDTTXAMonHocService tblQLDTTXAMonHocService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
    public String execute() throws Exception 
   { 
       try{ 
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_HocVien_HocPhi", "sua")){ 
        return "noprivilege"; 
    }
        tblQLDTTXAHocVienHocPhiService = (TblQLDTTXAHocVienHocPhiService) context.getBean("tbl_QLDTTXA_HocVien_HocPhiClient"); 
        tblQLDTTXAHocVienService = (TblQLDTTXAHocVienService) context.getBean("tbl_QLDTTXA_HocVienClient"); 

        tblQLDTTXAHocKyTrongNamService = (TblQLDTTXAHocKyTrongNamService) context.getBean("tbl_QLDTTXA_HocKyTrongNamClient"); 

        tblQLDTTXAHocVienHocPhiMonHocService = (TblQLDTTXAHocVienHocPhiMonHocService) context.getBean("tbl_QLDTTXA_HocVienHocPhi_MonHocClient"); 

        tblQLDTTXAMonHocService = (TblQLDTTXAMonHocService) context.getBean("tbl_QLDTTXA_MonHocClient"); 

        tblQLDTTXAHocVienHocPhi = tblQLDTTXAHocVienHocPhiService.gettblQLDTTXAHocVienHocPhi(new Long(id)); 
//        tblQLDTTXAHocViens = tblQLDTTXAHocVienService.findAlltblQLDTTXAHocVien(0, 0);

        tblQLDTTXAHocKyTrongNams = tblQLDTTXAHocKyTrongNamService.findAlltblQLDTTXAHocKyTrongNam(20, 1);

	   if (pageSize == 0) 
	   { 
	       pageSize = 20; 
	   } 
	   if (page == 0) 
	   { 
	       page = 1; 
	   } 
	   List<ConditionReport> cons = new ArrayList<ConditionReport>(); 
	cons.clear(); 
	   if (id != 0) 
	   { 
	       ConditionReport con = new ConditionReport(); 
	       con.setCol("hocVienHocPhiId.id"); 
	       con.setValue1(new Long(id)); 
	       con.setOperator("eq"); 
	       cons.add(con); 
	   } 
	   tblQLDTTXAHocVienHocPhiMonHocs = tblQLDTTXAHocVienHocPhiMonHocService.findtblQLDTTXAHocVienHocPhiMonHocByCondition(cons, pageSize, page); 
	   cons.clear(); 
   
//       tblQLDTTXAMonHocs =       tblQLDTTXAMonHocService.findAlltblQLDTTXAMonHoc(0, 0); 
       return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi EditForm tbl_QLDTTXA_HocVien_HocPhi Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
